package com.work.api.main;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.work.dto.main.OneStockTallyAppSubmitDTO;
import com.work.dto.main.OneStockTallySearchDTO;
import com.work.dto.main.RetreatSetAppSubmitDTO;
import com.work.dto.main.RetreatSetSearchDTO;
import com.work.service.main.IRetreatSetService;
import com.work.vo.main.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 退关设置控制器
 *
 * @author ：dujianyu
 * @since ：Created in 2024/5/27 13:31
 */
@RestController
@AllArgsConstructor
@RequestMapping("retreatSet")
@Api(value = "退关设置控制器", tags = "退关设置控制器")
public class RetreatSetController extends BladeController {

    private IRetreatSetService service;

    @PostMapping("/appSubmit")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "app提交（理货员理货）", notes = "传入dto")
    public R<Boolean> appSubmit(@Valid @RequestBody RetreatSetAppSubmitDTO dto) {
        return R.status(service.submitRetreatSet(dto));
    }

    @PostMapping("/remove")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "删除", notes = "传入id")
    public R<Boolean> remove(@ApiParam(value = "主键", required = true) @RequestParam String id) {
        return R.status(service.removeRetreatSet(Func.toLong(id)));
    }

    @GetMapping("/page")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "分页", notes = "传入dto")
    public R<IPage<RetreatSetVO>> selectRetreatSetPage(RetreatSetSearchDTO dto, Query query) {
        IPage<RetreatSetVO> pages = service.selectRetreatSetPage(Condition.getPage(query), dto);
        return R.data(pages);
    }

    @GetMapping("/retreatTallyList")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "提货操作列表", notes = "传入dto")
    public R<List<RetreatTallyVO>> selectRetreatTallyList(RetreatSetSearchDTO dto) {
        List<RetreatTallyVO> data = service.selectRetreatTallyList(dto);
        return R.data(data);
    }

    @GetMapping("/retreatTotal")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "退关总计", notes = "传入dto")
    public R<RetreatTotalVO> selectRetreatTotal(RetreatSetSearchDTO dto) {
        RetreatTotalVO data = service.selectRetreatTotal(dto);
        return R.data(data);
    }

    @GetMapping("/retreatSetStatPage")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "综合统计退关台账", notes = "传入dto")
    public R<IPage<RetreatSetStatVO>> selectRetreatSetStatPage(RetreatSetSearchDTO dto, Query query) {
        IPage<RetreatSetStatVO> data = service.selectRetreatSetStatPage(Condition.getPage(query), dto);
        return R.data(data);
    }

    @GetMapping("/retreatSetStatTotal")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "综合统计退关台账合计", notes = "传入dto")
    public R<RetreatTotalVO> selectRetreatSetStatTotal(RetreatSetSearchDTO dto) {
        RetreatTotalVO data = service.selectRetreatSetStatTotal(dto);
        return R.data(data);
    }

    @GetMapping("/retreatSetStatDetailPage")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "综合统计退关台账详情", notes = "传入dto")
    public R<IPage<RetreatSetStatDetailVO>> selectRetreatSetStatDetailPage(RetreatSetSearchDTO dto, Query query) {
        IPage<RetreatSetStatDetailVO> data = service.selectRetreatSetStatDetailPage(Condition.getPage(query), dto);
        return R.data(data);
    }

    @GetMapping("/retreatSetStatTallyPage")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "综合统计退关理货详情", notes = "传入dto")
    public R<IPage<RetreatSetStatTallyVO>> selectRetreatSetStatTallyPage(RetreatSetSearchDTO dto, Query query) {
        IPage<RetreatSetStatTallyVO> data = service.selectRetreatSetStatTallyPage(Condition.getPage(query), dto);
        return R.data(data);
    }
}
